//
//  UIGLESSettingViewController.m
//  TextureBlendPattern
//
//  Created by 畑圭輔 on 10/03/07.
//  Copyright 2010 Keisuke Hata. All rights reserved.
//

#import "UIGLESSettingViewController.h"


@implementation UIGLESSettingViewController

@synthesize glView;

- (IBAction) show {
	
	ControlView *view = (ControlView *)self.view;
	
	if( !_isOpened )
	{	
		[view open];
		_isOpened = YES;
		
	}else {
		[view close];
		_isOpened = NO;
		
	}
	NSLog(@"show view");
}

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
	
	_isOpened = NO;
	
	NSLog(@"viewLoad!!");
	CGRect frame = self.view.frame;
	frame.origin.y = self.view.frame.size.height - 40;
	_blendTypePicker.frame = CGRectMake(_blendTypePicker.frame.origin.x, 
										_blendTypePicker.frame.origin.y + 20, 
										_blendTypePicker.frame.size.width, 
										_blendTypePicker.frame.size.height);
	[self.view setFrame:frame];
    [super viewDidLoad];
	
	_blendTypes = [[NSArray arrayWithObjects:@"通常",@"加算",@"減算",@"乗算",@"スクリーン",@"反転",nil] retain];
}

#pragma mark -
#pragma mark UIPickerViewDataSource

// returns the number of 'columns' to display.
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {

	return 1;/* １列 */
}

// returns the # of rows in each component..
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
	
	return [_blendTypes count];
}

#pragma mark -
#pragma mark UIPickerViewDelegate

/*
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
	
}
 */

/*
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component {
}
 */

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
	
	return [_blendTypes objectAtIndex:row];
}

/*
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
	
}
 */

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {

	[glView updateBlendType:row];
	NSLog(@"ブレンドタイプを選択");
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}

- (void)dealloc {
    [super dealloc];
}


@end
